﻿(function(){function k(b){function e(a,c,d){if(a.text){var g=i?0:a.text.length-1,f=i?a.text.length:-1;for(null!=d&&(g=d+h);g!=f;g+=h)if(d=a.text.charAt(g),l.test(d)&&b.getTokenAt({line:c,ch:g+1}).type==k){var e=n[d];if(">"==e.charAt(1)==i)o.push(d);else{if(o.pop()!=e.charAt(0))return{pos:g,match:!1};if(!o.length)return{pos:g,match:!0}}}}}var a=b.getCursor(),f=b.getLineHandle(a.line),d=a.ch-1,c=0<=d&&n[f.text.charAt(d)]||n[f.text.charAt(++d)];if(!c)return null;for(var i=">"==c.charAt(1),h=i?1:-1,k=
b.getTokenAt({line:a.line,ch:d+1}).type,o=[f.text.charAt(d)],l=/[(){}[\]]/,c=a.line,j,m=i?Math.min(c+100,b.lineCount()):Math.max(-1,c-100);c!=m&&!(j=c==a.line?e(f,c,d):e(b.getLineHandle(c),c));c+=h);return{from:{line:a.line,ch:d},to:j&&{line:c,ch:j.pos},match:j&&j.match}}function l(b,e){var a=k(b);if(a){var f=a.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",d=b.markText(a.from,{line:a.from.line,ch:a.from.ch+1},{className:f}),c=a.to&&b.markText(a.to,{line:a.to.line,ch:a.to.ch+1},
{className:f}),a=function(){b.operation(function(){d.clear();c&&c.clear()})};if(e)setTimeout(a,800);else return a}}function m(b){b.operation(function(){h&&(h(),h=null);b.somethingSelected()||(h=l(b,!1))})}var n={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},h=null;CodeMirror.defineOption("matchBrackets",!1,function(b,e){if(e)b.on("cursorActivity",m);else b.off("cursorActivity",m)});CodeMirror.defineExtension("matchBrackets",function(){l(this,!0)});CodeMirror.defineExtension("findMatchingBracket",
function(){return k(this)})})();